package com.xxx.springboot.init;

import com.github.yitter.contract.IdGeneratorOptions;
import com.github.yitter.idgen.YitIdHelper;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/**
 * springboot启动后，执行
 */
@Component
public class Init implements CommandLineRunner {

    @Override
    public void run(String... args) throws Exception {
        // 创建 IdGeneratorOptions 对象，请在构造函数中输入 WorkerId：
        IdGeneratorOptions options = new IdGeneratorOptions((short)1);
        options.WorkerIdBitLength = 1;
        options.SeqBitLength = 3;
        YitIdHelper.setIdGenerator(options);
    }
}
